package com.dc.kotlinfinance.dao

import com.dc.kotlinfinance.model.StatisDaily
import com.dc.kotlinfinance.model.StatisticdailyRec
import org.apache.ibatis.annotations.Mapper
import org.apache.ibatis.annotations.SelectProvider
import org.apache.ibatis.jdbc.SQL
import org.springframework.stereotype.Component

/**
 *@createTime 2017/11/14 0014
 *@author DC
 */
@Mapper
@Component
interface RequestDao {

    @SelectProvider(type = RequestDaoPrivider::class, method = "getStatisticdaily")
    fun getStatisticdaily(rec:StatisticdailyRec) : List<StatisDaily>



    class RequestDaoPrivider{
        fun getStatisticdaily(rec: StatisticdailyRec): String {
            return object : SQL() {
                init {
                    SELECT("transaction_date statisDate", "valid_screen_count validScreenCount")
                    SELECT("play_times playTimes", "play_duration playDuration")
                    FROM("ssp_play_daily")
                    WHERE("customer_id = #{mediaProviderId} AND transaction_date BETWEEN #{startDate} AND #{endDate}")
                }
            }.toString()

        }


    }
}